home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacTech 1 to 12
/
MacTech-vol-1-12.toast
/
Reference
/
the cmsp digests ('94-'97)
/
csmp digest Vol 3 No 080
< prev
next >
Wrap
Text File
|
1995-01-25
|
41KB
|
1,295 lines
C.S.M.P. Digest Wed, 25 Jan 95 Volume 3 : Issue 80
Today's Topics:
Any special tricks for patching _Launch?
Auto Power on-off info anyone?
Bad Error in new MacTCP.h universal header file
Help! Regarding INITs
How do I do a scrolling list box?
Latest QuickTime Tech Notes
OpenDoc mailing list or FAQ?
Q: Bedrock Exception Library Questions
help with CLUT-Palette management
The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
(pottier@clipper.ens.fr).
The digest is a collection of article threads from the internet newsgroup
comp.sys.mac.programmer. It is designed for people who read c.s.m.p. semi-
regularly and want an archive of the discussions. If you don't know what a
newsgroup is, you probably don't have access to it. Ask your systems
administrator(s) for details. If you don't have access to news, you may
still be able to post messages to the group by using a mail server like
anon.penet.fi (mail help@anon.penet.fi for more information).
Each issue of the digest contains one or more sets of articles (called
threads), with each set corresponding to a 'discussion' of a particular
subject. The articles are not edited; all articles included in this digest
are in their original posted form (as received by our news server at
nef.ens.fr). Article threads are not added to the digest until the last
article added to the thread is at least two weeks old (this is to ensure that
the thread is dead before adding it to the digest). Article threads that
consist of only one message are generally not included in the digest.
The digest is officially distributed by two means, by email and ftp.
If you want to receive the digest by mail, send email to listserv@ens.fr
with no subject and one of the following commands as body:
help Sends you a summary of commands
subscribe csmp-digest Your Name Adds you to the mailing list
signoff csmp-digest Removes you from the list
Once you have subscribed, you will automatically receive each new
issue as it is created.
The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
Questions related to the ftp site should be directed to
scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
digest are available there.
Also, the digests are available to WAIS users. To search back issues
with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
-------------------------------------------------------
>From valuefax@netcom.com (Pancomm)
Subject: Any special tricks for patching _Launch?
Date: Mon, 9 Jan 1995 05:35:42 GMT
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
Greetings,
Are there any special tricks for patching _Launch? I am trying to
patch _Launch to determine if a program from a particular set is being
started. I catch the launch of Multifinder on startup but after that I
don't catch anything. I suspect Multifinder overrides my patch and does
not bother to call my patch routine before or after it does its thing.
What am I doing wrong? My other patches (_ExitToShell, _Open, _Close) are
working fine so I am sure my method of patching is working. This is on
system 7.5 but earlier systems probable behave the same.
Please help with any pointers or suggestions. Users of ValueFax and
myself will be very grateful.
TIA.
Pancomm.
+++++++++++++++++++++++++++
>From haynes@asel.udel.edu (Carl W. Haynes III)
Date: Mon, 09 Jan 1995 02:49:43 -0500
Organization: Univ. of Delaware
In article <valuefaxD24I7J.50v@netcom.com>, valuefax@netcom.com (Pancomm) wrote:
> Greetings,
> Are there any special tricks for patching _Launch? I am trying to
> patch _Launch to determine if a program from a particular set is being
> started. I catch the launch of Multifinder on startup but after that I
> don't catch anything. I suspect Multifinder overrides my patch and does
> not bother to call my patch routine before or after it does its thing.
I think you're right about Multifinder patching out _Launch, How about
patching _InitGraf instead, or patching GetResource (looking for 'CODE'
resource 0).
carl
--
Get1Resource -- A Mac Programming WebZine
http://www.asel.udel.edu/~haynes/g1r.html
+++++++++++++++++++++++++++
>From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
Date: Tue, 10 Jan 1995 09:38:15 +0800
Organization: Department of Computer Science, University of Western Australia
In article <haynes-0901950249430001@abyss.asel.udel.edu>,
haynes@asel.udel.edu (Carl W. Haynes III) wrote:
>In article <valuefaxD24I7J.50v@netcom.com>, valuefax@netcom.com (Pancomm)
wrote:
>
>> Are there any special tricks for patching _Launch? I am trying to
>> patch _Launch to determine if a program from a particular set is being
>> started. I catch the launch of Multifinder on startup but after that I
>> don't catch anything. I suspect Multifinder overrides my patch and does
>> not bother to call my patch routine before or after it does its thing.
Yep.
>I think you're right about Multifinder patching out _Launch, How about
>patching _InitGraf instead, or patching GetResource (looking for 'CODE'
>resource 0).
Yep, patching _InitGraf is a better way of doing it. Be careful if you do
it that way though, things calling _InitGraf may not be applications. For
example any INIT that shows an icon calls _InitGraf. There are also a
variety of other, infrequently used, Toolbox traps that you can patch that
most applications will call when they start up.
I have successfully managed to patch _Launch but I needed to prevent
launches rather than just monitor them. I wouldn't recommend my method (:
Don't you just wish that support for this was in the Process Manager???
Share and Enjoy.
--
Quinn "The Eskimo!" "Ah, so that's the secret,
if only Captain Bipto had known.
---------------------------
>From david.matusow@gsfc.nasa.gov (David Matusow)
Subject: Auto Power on-off info anyone?
Date: Mon, 09 Jan 1995 11:01:15 -0500
Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
I was wondering if anyone knows how apple's Auto Power On/Off control
panel does the power on? How does the program run when the Mac is off,
and is there some way for us developers to do a similar thing?
Thanks,
--David
--
David Matusow
NASA - GSFC
email -> david.matusow@gsfc.nasa.gov
+++++++++++++++++++++++++++
>From Jeff@purple.com (Jeff Abrahamson)
Date: 11 Jan 1995 22:07:17 -0500 (EST)
Organization: Purple Software
In article <david.matusow-0901951101150001@129.188.12.62>
david.matusow@gsfc.nasa.gov (David Matusow) writes:
>I was wondering if anyone knows how apple's Auto Power On/Off control
>panel does the power on? How does the program run when the Mac is off,
>and is there some way for us developers to do a similar thing?
It's pretty clever, actually. It makes use, as you may have guessed since you
posted this, of the Subspace Manager (see Develop, issue 7). When you request
the Auto on/off control panel to turn your Mac on at a certain time, it uses
the Subspace Manager to request a Mac in an alternate universe to signal your
Mac at the appropriate time. The Subspace circuitry may be activated even when
main power is off (it's a very low power device), and it is thus able to raise
a power on signal, bringing up your Mac.
Note that the apparent lack of correlation between our time line and time lines
in parallel universes allows the Mac in the parallel universe to send the
signal to start your Mac almost immediately after receiving the signal from
your Mac. This increases reliability, since it's unlikely the Mac in the
alternate universe will be off when you need it. See the appropriate header
files in the Subspace section of the MacOS SDK. (The SubspaceParamBlock has a
field for time, although this is usually left zero, meaning default time.)
Originally Apple was going to use the Advanced Time Services Manager, but it
was a bit tricky to signal the same Mac in the future, even with the ATSM-aware
chips, and those chips were eventually cut by Apple anyway, canning the
project.
Contact Jens Alfke for further information on ATSM. I think he wrote the
definitive article on it last year in csmp....
Jeff Abrahamson
PDI
jeff@purple.com
jeff31415@aol.com
---------------------------
>From j-norstad@nwu.edu (John Norstad)
Subject: Bad Error in new MacTCP.h universal header file
Date: Sat, 07 Jan 1995 21:07:01 -0600
Organization: Northwestern University
There's a bad error in the new MacTCP.h file in version 2.0a3 of Apple's
universal headers (at least, in the copy on the new CodeWarrior Release 5
CD). If your program uses MacTCP, and you are working with the new
MacTCP.h file, this could be rather important.
TCPSendPB is defined as follows in MacTCP.h:
struct TCPSendPB {
SInt8 ulpTimeoutValue;
SInt8 ulpTimeoutAction;
SInt8 validityFlags;
UInt8 filler; /* Filler for proper byte alignment */
Boolean pushFlag;
Boolean urgentFlag;
Ptr wdsPtr;
unsigned long sendFree;
unsigned short sendLength;
Ptr userDataPtr;
};
The filler byte is in the wrong place. The proper definition is:
struct TCPSendPB {
SInt8 ulpTimeoutValue;
SInt8 ulpTimeoutAction;
SInt8 validityFlags;
Boolean pushFlag;
Boolean urgentFlag;
UInt8 filler; /* Filler for proper byte alignment */
Ptr wdsPtr;
unsigned long sendFree;
unsigned short sendLength;
Ptr userDataPtr;
};
For example, if you try to set the push flag with the bogus version of the
MacTCP.h header file, you send up setting the urgent flag instead! This
caused big problems with a new version of NewsWatcher I released
yesterday.
Moral: People who live on the edge and are the first to use new
development tools (from Apple or elsewhere) sometimes fall off and get
what they deserve.
--
John Norstad
Academic Computing and Network Services
Northwestern University
j-norstad@nwu.edu
---------------------------
>From u567510@csi.uottawa.ca (Patricke Coutue the Firste)
Subject: Help! Regarding INITs
Date: 29 Dec 1994 12:26:54 GMT
Organization: Dept. of Computer Science, University of Ottawa
On the subject of INITs, is there a way to time when the INIT runs? I want
an INIT I am running to execute AFTER QuickTime, cause I want the INIT
to play a .moov. Mind you, I get the "unimplemented trap" crash, which
is incredibly annoying.
I am a complete and utter novice, any help with this project appreciated.
+++++++++++++++++++++++++++
>From gurgle@dnai.com (Pete Gontier)
Date: Thu, 29 Dec 1994 11:23:15 -0700
Organization: cellular
In article <3du9ue$3m3@csi0.csi.UOttawa.CA>, u567510@csi.uottawa.ca
(Patricke Coutue the Firste) wrote:
> On the subject of INITs, is there a way to time when the INIT runs? I want
> an INIT I am running to execute AFTER QuickTime...
With respect to reliance on the way the system calls extensions, you have
two options:
(1) Name your extension something alphabetically later than QuickTime,
document this fact, and hope that your users don't rename it.
Don't simply settle for telling them it must run last, because
that creates competition with other extensions which impose
similar requirements. I believe the usual thing to do is to prepend
a '~' onto whatever name you'd otherwise like to use.
(2) Have your installer put your extension in the System Folder so that
its name is less important. Users could still move your extension
into the Extensions folder, and Finder will offer to do so if the
user ever disables your extension by dragging it out of the System
Folder sub-tree and then enables it by dragging it onto the System
Folder icon.
Or, if QuickTime is not already present when your INIT is called, it can
patch into some system routine and either:
(1) Wait for extension loading time to be over. (In general, but perhaps
not for your purposes, patching _Launch works, as do several other
things.)
(2) Check to see if QuickTime has been loaded every time that system
routine is called. (Patching CloseResFile and watching for QuickTime
being closed [see PBGetFCBInfo] might be useful here.)
Of course, you might wish to employ more than one of these techniques.
In all cases you must determine whether QuickTime is present before
calling it. Although it is installed by default under System 7.5, users
are perfectly capable of removing it.
______________________________________________________________________________
Pete Gontier -- MacZealotry, Ink. -- gurgle@dnai.com
Where do I want to go today? Anywhere but Chicago.
+++++++++++++++++++++++++++
>From walkerj@math.scarolina.edu (James W. Walker)
Date: Sat, 07 Jan 1995 21:31:11 -0500
Organization: Dept. of Mathematics, Univ. of South Carolina
In article <ericstadD1v6tG.5Dx@netcom.com>, ericstad@netcom.com (Eric
Stadtherr) wrote:
...
> If playing when the Finder starts up is good enough, just set up a
> Notification Manager task to play the movie for you. This will guarantee
> that QuickTime has been loaded (if present).
Slight "gotcha": Certain extensions (Desktop Reset comes to mind) display
a dialog during startup time, and cause notifications to fire
prematurely. The workaround is to make the response procedure reinstall
the notification if the time is not ripe.
--
Jim Walker
---------------------------
>From timmyd@netcom.com (Tim DeBenedictis)
Subject: How do I do a scrolling list box?
Date: Tue, 10 Jan 1995 02:48:38 GMT
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
This is probably a FAQ, but...
How do I implement a scrolling list box in a modal dialog window?
Does anybody know where I can find some reliable example code for this?
Thanks in advance,
Tim DeBenedictis
+++++++++++++++++++++++++++
>From Lars Travers <ltravers@igc.apc.org>
Date: 10 Jan 1995 16:51:40 GMT
Organization: Tufts University
In article <timmydD26552.DED@netcom.com> Tim DeBenedictis,
timmyd@netcom.com writes:
>How do I implement a scrolling list box in a modal dialog window?
>Does anybody know where I can find some reliable example code for this?
see the book _Macintosh Programming Secrets_ by Scott Knaster and Keith
Rollin page 429 (2nd edition, Addison-Wesley Publishing).
+++++++++++++++++++++++++++
>From oster@netcom.com (David Phillip Oster)
Date: Tue, 10 Jan 1995 17:09:35 GMT
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
In article <timmydD26552.DED@netcom.com> timmyd@netcom.com (Tim DeBenedictis) writes:
>How do I implement a scrolling list box in a modal dialog window?
>Does anybody know where I can find some reliable example code for this?
One way:
in your resources:
declare a user item in your ditl, and have your dialog be initially invisible.
in your program:
GetNewDialog() to bring the dialog in.
get your user item's rect.
LNew() an appripriate listHnadle.
Set the update procedure (i.e., the handle) of the user item to
similarly to:
static ListHandle myListHandle = NULL;
static UpdateUPP updateUPP = NULL;
static pascal void UpdateList(DialogPtr dp, short item){
LUpdate( dp->visRgn, myListHandle);
}
GetItem(kDLOGsUserItem, &type, &id, &dontCare);
if(NULL != updateUPP){
updateUPP = NewUpdateUPP(UpdateList);
}
SetItem(kDLOGsUserItem, type, id, (Handle) updateUPP);
You can ignore the UPP stuff and just set UpdateList directly into SetItem
if you don't care about fat binaries. The above schema doesn't need to be
modified if you are compiling for a 68000 instead of PowerPC, since
UpdateUPP will expand to a variable of type procedure pointer, and
NewUpdateUPP() just returns its argument on the 68000. On the PowerPC
an appropriate data structure will be allocated and initialized.
last things:
Remember to LDispose() you list handle when you are done with it.
You'll need to filter events in ModalDialog() or in your event loop,
and handle clicks in the userItem yourself, by passing them to LClick
(convert from global to local.)
Figure a half day for the first one.
--
- ------- oster@netcom.com ----------
"A man hears what he wants to hear and misremembers the rest."
-- Paul Simon, ("The Boxer")
+++++++++++++++++++++++++++
>From mxmora@unix.sri.com (Matthew Xavier Mora)
Date: Tue, 10 Jan 1995 10:00:48 -0800
Organization: SRI International
In article <timmydD26552.DED@netcom.com>, timmyd@netcom.com (Tim
DeBenedictis) wrote:
> This is probably a FAQ, but...
>
> How do I implement a scrolling list box in a modal dialog window?
> Does anybody know where I can find some reliable example code for this?
>
> Thanks in advance,
>
> Tim DeBenedictis
Here is a snippet that I used from Steve Falkenburg. I was using it to
test Script compiling.
/*
Modal Dialog TextEdit useritem snippet
Steve Falkenburg-- MacDTS
This snippet shows the steps necessary to implement a scrolling,
editable text field
in a dialog. You may want to do this if you will be requiring the user
to enter more than
255 characters (the limit for editText items), if you want a different
font for several
different editText items, or it you want to add scrolling support to an
editible text item.
*/
#include <AppleScript.h>
// constants
#define kMyDialog 128
#define kInFront (WindowPtr)-1L
#define kEditTextItem 2
#define kScrollerItem 3
#define kMargin 4
#define kPageLines 16
#define kScrollToTop 0
#define kScrollToBottom 1
#define kMaxLines 128
#define kOSACompile 5
#define kOSAExecute 6
#pragma mark Prototypes
void main(void);
void InitStuff(void);
void DoDialog(void);
void SetupDialog(DialogPtr theDialog);
void PrepareFreeDialog(DialogPtr theDialog);
pascal void EditTextDrawProc(DialogPtr theDialog,short theItem);
pascal Boolean MyDialogFilter(DialogPtr theDialog,EventRecord *ev,short
*itemHit);
void HandleKeyPress(DialogPtr theDialog,char theChar);
void HandleIdle(DialogPtr theDialog);
void HandleActivate(DialogPtr theDialog);
Boolean HandleMouse(DialogPtr theDialog,Point pt,short modifiers);
void HandleScroller(DialogPtr theDialog,Point pt);
pascal void ScrollBarAction(ControlHandle theControl,short part);
void ScrollText(DialogPtr theDialog,short lines);
void ReAlignTextToScrollbar(DialogPtr theDialog);
void ReAlignScrollbarToText(DialogPtr theDialog);
pascal Boolean MyTEClickProc(void);
ControlHandle GetScrollBar(DialogPtr theDialog);
TEHandle GetTEHandle(DialogPtr theDialog);
#pragma mark Globals
ModalFilterUPP gMyDialogFilterUPP ;
UserItemUPP gEditDrawUPP;
TEClickLoopUPP gTEClickLoopUPP;
ControlActionUPP gScrollBarUPP;
extern OSAID gContext;
OSAID gScriptID;
#pragma mark -
/* main entry point */
//----------------------------------------------------------------
void main(void)
//----------------------------------------------------------------
{
InitStuff();
DoDialog();
ExitToShell();
}
/* initialize the Mac managers */
//----------------------------------------------------------------
void InitStuff(void)
//----------------------------------------------------------------
{
InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();
FlushEvents(everyEvent,0);
gMyDialogFilterUPP = NewModalFilterProc(MyDialogFilter);
gEditDrawUPP = NewUserItemProc(EditTextDrawProc);
gTEClickLoopUPP = NewTEClickLoopProc(MyTEClickProc);
gScrollBarUPP = NewControlActionProc(ScrollBarAction);
}
//----------------------------------------------------------------
void DoCompile(DialogPtr theDialog)
//----------------------------------------------------------------
{
TEHandle te = GetTEHandle(theDialog);
Handle h;
h = (**te).hText;
HLock(h);
gScriptID = CompileText(h);
HUnlock(h);
}
//----------------------------------------------------------------
void DoExecute(gScriptID)
//----------------------------------------------------------------
{
short err;
err = ExecuteScript( gScriptID);
}
/* display dialog, and handle pretty standard ModalDialog loop. The modal
dialog loop doesn't
handle item hits to the scroll bar or text items. These are handled
through the filter
procedure
*/
//----------------------------------------------------------------
void DoDialog(void)
//----------------------------------------------------------------
{
DialogPtr theDialog;
short item;
ControlHandle checkBoxControl;
short iType;
Rect iRect;
theDialog = GetNewDialog(kMyDialog,nil,kInFront);
SetupDialog(theDialog);
InitCompiler();
do {
ModalDialog(gMyDialogFilterUPP,&item);
switch (item) {
case kOSACompile:
DoCompile(theDialog);
break;
case kOSAExecute:
DoExecute(gScriptID);
break;
}
} while (item!=ok);
PrepareFreeDialog(theDialog);
DisposeDialog(theDialog);
}
/* Creates the necessary data structures necessary to use the textedit
item in our dialog. A
handle to the TextEdit record is stored in the Dialog's window refCon field.
*/
//----------------------------------------------------------------
void SetupDialog(DialogPtr theDialog)
//----------------------------------------------------------------
{
short iType;
Handle iHndl;
Rect iRect;
ControlHandle theControl;
short fontNum;
TEHandle theTE;
SetPort(theDialog);
GetDialogItem(theDialog,kScrollerItem,&iType,(Handle
*)&theControl,&iRect); // set up the scroll bar
SetCtlMin(theControl,0); // (it's stored
in a CNTL)
SetCtlMax(theControl,kMaxLines);
GetDItem(theDialog,kEditTextItem,&iType,&iHndl,&iRect);
SetDItem(theDialog,kEditTextItem,iType,(Handle)gEditDrawUPP,&iRect);
InsetRect(&iRect,kMargin,kMargin);
GetFNum("\pgeneva",&fontNum);
TextFont(fontNum);
theTE = TENew(&iRect,&iRect); // create our textedit item
GetFNum("\pchicago",&fontNum);
TextFont(fontNum);
TESetClickLoop(gTEClickLoopUPP,theTE); // callback for drag-scrolling
TEAutoView(true,theTE); // turn auto-scroll on for text entry
SetWRefCon(theDialog,(long)theTE);
}
/* free the memory taken by the textedit record before closing the dialog
*/
void PrepareFreeDialog(DialogPtr theDialog)
{
TEHandle theTE;
theTE = GetTEHandle(theDialog);
TEDispose(theTE);
}
/* dialog user item draw procedure for text box. It just calls FrameRect
*/
pascal void EditTextDrawProc(DialogPtr theDialog,short theItem)
{
short iType;
Handle iHndl;
Rect iRect;
GrafPtr savePort;
GetPort(&savePort);
SetPort(theDialog);
GetDItem(theDialog,theItem,&iType,&iHndl,&iRect);
FrameRect(&iRect);
SetPort(savePort);
}
/* this is the main dispatcher for events to be passed off to the scroll
bar or textedit box.
looks sort of like a WaitNextEvent event handler.
*/
pascal Boolean MyDialogFilter(DialogPtr theDialog,EventRecord *ev,short
*itemHit)
{
char theChar;
switch (ev->what) {
case keyDown:
case autoKey:
theChar = (ev->message & charCodeMask);
HandleKeyPress(theDialog,theChar);
return true;
case nullEvent:
HandleIdle(theDialog);
return false;
case activateEvt:
HandleActivate(theDialog);
return false;
case mouseDown:
return HandleMouse(theDialog,ev->where,ev->modifiers);
default:
return false;
}
}
/* dialog filter event handler for keypresses. All keypresses are passed
to the textedit box
*/
void HandleKeyPress(DialogPtr theDialog,char theChar)
{
TEHandle theTE;
theTE = GetTEHandle(theDialog);
TEKey(theChar,theTE);
ReAlignScrollbarToText(theDialog);
}
/* handler for null events. used in our case to blink the insertion point
*/
void HandleIdle(DialogPtr theDialog)
{
TEHandle theTE;
theTE = GetTEHandle(theDialog);
TEIdle(theTE);
}
/* activate event handler. we take this opportunity to call TEActivate to
activate the textedit
box
*/
void HandleActivate(DialogPtr theDialog)
{
TEHandle theTE;
theTE = GetTEHandle(theDialog);
TEActivate(theTE);
}
/* mouse-down hander. here, we see if the mousedown was in the scrollbar
or in the textedit
record. if in the textedit item, we call teclick. If in the
scrollbar, we call handlescroller
to do further processing
*/
Boolean HandleMouse(DialogPtr theDialog,Point pt,short modifiers)
{
short iType;
Handle iHndl;
Rect textRect,scrollerRect;
TEHandle theTE;
GrafPtr savePort;
Boolean shiftDown,result;
ControlHandle theControl;
short part;
GetPort(&savePort);
SetPort(theDialog);
shiftDown = modifiers & shiftKey;
GlobalToLocal(&pt);
GetDItem(theDialog,kEditTextItem,&iType,&iHndl,&textRect);
GetDItem(theDialog,kScrollerItem,&iType,&iHndl,&scrollerRect);
if (PtInRect(pt,&textRect)) {
theTE = GetTEHandle(theDialog);
TEClick(pt,shiftDown,theTE);
result = true;
}
else if (PtInRect(pt,&scrollerRect)) {
HandleScroller(theDialog,pt);
result = true;
}
else
result = false;
SetPort(savePort);
return result;
}
/* here, we see which part of the scrollbar was clicked in by calling
findcontrol. trackcontrol
is then called with the appropriate action proc if in one of the
buttons or page areas. if
in the thumb, the text is simply re-aligned to the new scrollbar position
*/
void HandleScroller(DialogPtr theDialog,Point pt)
{
short part;
ControlHandle theControl;
part = FindControl(pt,theDialog,&theControl);
switch (part) {
case inUpButton:
case inDownButton:
case inPageUp:
case inPageDown:
TrackControl(theControl,pt,gScrollBarUPP);
break;
case inThumb:
TrackControl(theControl,pt,nil);
ReAlignTextToScrollbar(theDialog);
break;
}
}
/* trackcontrol callback used to determine which direction to scroll the
text, and by how much.
once this is known, the text is scrolled, and the scrollbar adjusted.
*/
pascal void ScrollBarAction(ControlHandle theControl,short part)
{
DialogPtr theDialog;
short lines;
short ctlValue,ctlMax,ctlMin;
ctlMax = GetCtlMax(theControl);
ctlMin = GetCtlMin(theControl);
ctlValue = GetCtlValue(theControl);
theDialog = (*theControl)->contrlOwner;
switch (part) {
case inUpButton:
lines = -1;
break;
case inDownButton:
lines = 1;
break;
case inPageUp:
lines = -kPageLines;
break;
case inPageDown:
lines = kPageLines;
break;
default:
return;
}
if ((ctlValue+lines)>ctlMax)
lines = ctlMax-ctlValue;
if ((ctlValue+lines)<ctlMin)
lines = ctlMin-ctlValue;
if (lines!=0) {
ScrollText(theDialog,lines);
SetCtlValue(theControl,ctlValue+lines);
}
}
/* sets the text top line to be the same as the current scrollbar
position. this is called after
a thumb movement in the scrollbar.
*/
void ReAlignTextToScrollbar(DialogPtr theDialog)
{
TEHandle theTE;
ControlHandle scrollBar;
short controlScrollPosition,textScrollPosition,scrollDelta,scrollPix;
theTE = GetTEHandle(theDialog);
scrollBar = GetScrollBar(theDialog);
controlScrollPosition = GetCtlValue(scrollBar);
textScrollPosition = ((**theTE).viewRect.top - (**theTE).destRect.top)
/ (**theTE).lineHeight;
scrollDelta = textScrollPosition - controlScrollPosition;
scrollPix = scrollDelta * (*theTE)->lineHeight;
TEScroll(0,scrollPix,theTE);
}
/* sets the scrollbar thumb to the current text position. this is called
after autoscrolling,
which may occur after a call to TEKey, or during a drag-scroll
*/
void ReAlignScrollbarToText(DialogPtr theDialog)
{
TEHandle theTE;
ControlHandle scrollBar;
short textScrollPosition;
theTE = GetTEHandle(theDialog);
scrollBar = GetScrollBar(theDialog);
textScrollPosition = ((**theTE).viewRect.top - (**theTE).destRect.top)
/ (**theTE).lineHeight;
SetCtlValue(scrollBar,textScrollPosition);
}
/* scrolls the text by the delta passed in to the function. called in
response to clicking the
arrows or page areas of the scrollbar to move the text
*/
void ScrollText(DialogPtr theDialog,short lines)
{
TEHandle theTE;
short scrollPix;
short textScrollPosition;
theTE = GetTEHandle(theDialog);
textScrollPosition = ((**theTE).viewRect.top - (**theTE).destRect.top)
/ (**theTE).lineHeight;
if ((textScrollPosition+lines)<0)
lines = -textScrollPosition;
if ((textScrollPosition+lines)>kMaxLines)
lines = kMaxLines-textScrollPosition;
scrollPix = lines * (*theTE)->lineHeight;
TEScroll(0,-scrollPix,theTE);
}
/* text drag callback procedure. this routine handles drag scrolling by
checking to see if we
are in the area where drag-scrolling is necessary, and calling
scrolltext followed by a
scrollbar realignment
*/
pascal Boolean MyTEClickProc(void)
{
Point pt;
DialogPtr theDialog;
ControlHandle theControl;
TEHandle theTE;
Rect textRect;
short scrollLines;
GrafPtr savePort;
RgnHandle saveClip;
GetMouse(&pt);
theDialog = (DialogPtr)FrontWindow();
theTE = GetTEHandle(theDialog);
GetPort(&savePort);
SetPort(theDialog);
saveClip = NewRgn();
GetClip(saveClip);
ClipRect(&theDialog->portRect);
scrollLines = 0;
textRect = (**theTE).viewRect;
if (pt.v < textRect.top)
scrollLines = -1;
else if (pt.v > textRect.bottom)
scrollLines = 1;
if (scrollLines) {
ScrollText(theDialog,scrollLines);
ReAlignScrollbarToText(theDialog);
}
SetClip(saveClip);
DisposeHandle((Handle)saveClip);
SetPort(savePort);
return true;
}
/* utility procedure to return a handle to the scrollbar control
*/
ControlHandle GetScrollBar(DialogPtr theDialog)
{
ControlHandle theScroller;
short iType;
Rect iRect;
GetDItem(theDialog,kScrollerItem,&iType,(Handle *)&theScroller,&iRect);
return theScroller;
}
/* utility procedure to return the textedit record for the given dialog */
TEHandle GetTEHandle(DialogPtr theDialog)
{
return( (TEHandle)GetWRefCon((WindowPtr)theDialog) );
}
--
__________________________________________________________________
Matthew Xavier Mora (cybernaut) The keeper of the UMPG
SRI International mxmora@unix.sri.com
__________________________________________________________________
---------------------------
>From sandvik@apple.com (Kent Sandvik)
Subject: Latest QuickTime Tech Notes
Date: Sat, 07 Jan 1995 20:03:20 -0800
Organization: Apple Computer, Inc. Developer Technical Support
We have brand new (sort of) Tech Notes for QuickTime, these will go out
with various developer distributions, but I uploaded them to the
ftp.apple.com dts directory (dts/multimedia/quicktime), or:
"ftp://ftp.apple.com/dts/multimedia/quicktime/LatestTNs/QT01 - QuickTime.hqx"
"ftp://ftp.apple.com/dts/multimedia/quicktime/LatestTNs/QT02 - QuickTime
Comp.hqx"
"ftp://ftp.apple.com/dts/multimedia/quicktime/LatestTNs/QT03 - QTW.hqx"
What's new since the last time any QuickTime related TNs were released?
* There's just these three Tech Notes, they all correspond to the Inside
Macintosh QuickTime books, even on chapter level. If you don't find
something in the NIM QuickTime books in a chapter, do a second lookup in
the Tech Notes. This is easier than searching in a multitude of Tech
Notes. Thus, all information is re-classified so it falls into the
categories defined by the NIM books.
* The Q&A entries are in many cases rewritten and placed into these Tech
Notes as well, so you don't need to check these TNs out as well (they are
gone).
* All relevant information up to December 1994 is now in the Tech Notes,
including email Q&A entries DTS has answered for the last 12 months. This
also includes errata notes concerning the NIM QuickTime books.
* Anything not relevant to QT 2.0/1.6.1 is now out from the Tech Notes.
In future we hope to update these TNs more frequently, for instance it's
doable to publish a separate delta document with the new information since
December 1994, so if you want to just check out what's new you don't need
to read the bigger Tech Notes (even if it's in there as well).
If you have any feedback about the Tech Notes, the contents or the
process, feel free to send me an email. You should see these TNs appearing
over the normal channels, but I didn't want them to gather dust as they
are finished already :-).
--Kent
--
Kent Sandvik sandvik@apple.com New Media Analyst/Programmer
Private activities on Internet.
---------------------------
>From jdv@netcom.com (Julian Vrieslander)
Subject: OpenDoc mailing list or FAQ?
Date: Sat, 7 Jan 1995 23:27:12 GMT
Organization: Cornell University, Ithaca, NY
Title line pretty much sums it up. Besides the articles in MacTech and
the OpenDoc CD-ROM, where should I look for info to help me come up to
speed on OpenDoc?
--
Julian Vrieslander
jdv@netcom.com jdv2@cornell.edu
+++++++++++++++++++++++++++
>From Alan Harper <aharper@dnai.com>
Date: 7 Jan 1995 18:05:31 GMT
Organization: Eclectus
In article <jdvD226HD.J6y@netcom.com> Julian Vrieslander, jdv@netcom.com
writes:
> Title line pretty much sums it up. Besides the articles in MacTech and
> the OpenDoc CD-ROM, where should I look for info to help me come up to
> speed on OpenDoc?
send a message
SUBSCRIBE OPENDOC-ANNOUNCE <your name>
SUBSCRIBE OPENDOC-INTEREST <your name>
to listproc@CILabs.ORG
- ---------------
Alan Harper aharper@dnai.com
77 Jack London Sq, Ste. H 510/444-6605 (voice/fax)
Oakland, CA 94607
---------------------------
>From ericg@cs.uoregon.edu (MystryMan)
Subject: Q: Bedrock Exception Library Questions
Date: 9 Jan 1995 15:43:17 -0800
Organization: University of Oregon Computer and Information Sciences Dept.
I was reading through some of the CodeWarrior documentation and it said that
"The Bedrock Exception Library which was added to the TCL in version 2.0 seems
to be somewhat buggy, especially on the PowerPC"
Unfortunatly, it does not go on to specify where these bugs come into play,
what they are or how to avoid them.
I would like to continue to use the BEL for now and would like more information
on what these bugs are.
Thanx..
===Eric Gorr================ericg@cs.uoregon.edu===========aka MystryMan===
_____
|\ /| * Invincibility is in oneself, vulnerability is in the opponent
| O | * Therefore the considerations of the intelligent always include both
|/_\| benefit and harm (Sun Tzu)
#include <standard.disclaimer>
=====Insults, like violence, are the last resort of the incompetent...=====
+++++++++++++++++++++++++++
>From afcjlloyd@aol.com (AFC JLloyd)
Date: 11 Jan 1995 17:15:35 -0500
Organization: America Online, Inc. (1-800-827-6364)
>I was reading through some of the CodeWarrior documentation and it said
that
>
>"The Bedrock Exception Library which was added to the TCL in version 2.0
seems
>to be somewhat buggy, especially on the PowerPC"
>
>Unfortunatly, it does not go on to specify where these bugs come into
play,
>what they are or how to avoid them.
>
>I would like to continue to use the BEL for now and would like more
information
>on what these bugs are.
I'm the engineer who has done most of the work on BEL. There is an
extensive test suite for BEL that was written by myself and a quality
assurance engineer (David Dodd). We've run that test suite on multiple
compilers and platforms (Symantec C++ for MPW, Symantec C++ for Think
Project Manager, Symantec C++ for Windows, Borland C++, Metrowerks C++,
Apple's MrC). BEL is being used in shipping applications on both Mac and
Windows.
I have heard rumors that BEL is buggy. When looking into these rumors the
only problem that I have been able to confirm is one where a register
value is not preserved across the longjmp. This is easily fixed by proper
use of the C++ keyword volatile. If you need a local value to be
preserved from the TRY block to the CATCH block when an exception is
thrown, be sure to declare the value volatile. Here are some examples:
TRY
{
volatile int i;
CMyClass * volatile myClassPtr;
}
Note the postion of the volatile keyword when declaring a pointer. The
keyword must come after the *, not before.
If anyone is aware of any bugs in BEL, please send mail to me at one of
the addresses below. To my knowledge there are NO bugs in BEL, though
there are some limitations that may not be fully documented. Here are two
limitations to be aware of:
BEL has a hard time in some cases with TRY/CATCH blocks nested inside of a
CATCH block. In particular, you can only THROW_SAME from within the
innermost nested CATCH block.
If you want to embed an autodestruct object by value inside of another
object, then the outer object must also be an autodestruct object, and it
should have the END_CONSTRUCTOR/START_DESTRUCTOR macros inside of its
constructors and destructor.
Finally be aware of the fact that if you don't create one, the compiler
will write a copy constructor for you. A compiler-generated copy
constructor won't have the END_CONSTRUCTOR macro. If the destructor has a
START_DESTRUCTOR macro, then you will get an assertion failure when that
object is destroyed.
Jim Lloyd
afcjlloyd@aol.com -or- Jim_Lloyd@powertalk.apple.com
---------------------------
>From allender@prairienet.org (Mark W. Allender)
Subject: help with CLUT-Palette management
Date: 10 Jan 1995 20:01:15 GMT
Organization: Prairienet, the East-Central Illinois Free-Net
I have a very simple problem that I am trying desperately to solve.
I have a palette of 256 colors that I want to display in a simple little
grid format. I am having no trouble doing the actual drawing. The problem
is that I don't understand (after wading through endless volumes of Inside
Macintosh, developer notes, etc) how the palette and color table manager
work to produce colors for a particular window.
In my case, all I want to do is replace the first 256 entries in my
windows color table, and draw my little grid. It appears to me that I
still have the system colors when I do this.
What I tried initially was to create a Palette with my entries, used
palette2CTab, and then placed the CTable into the Pixmap area pointed
to by the window that I created. Sounded simple, but doesn't work.
Can some kind soul help me out with this seemingly simple task. Thanks
in advance!!!
--
-Mark Allender
-Parallax Software
-allender@prairienet.org
+++++++++++++++++++++++++++
>From gurgle@dnai.com (Pete Gontier)
Date: Tue, 10 Jan 1995 18:41:18 -0700
Organization: cellular
In article <3eup2b$oae@vixen.cso.uiuc.edu>,
allender@prairienet.org (Mark W. Allender) wrote:
> In my case, all I want to do is replace the first 256 entries in my
> windows color table...
No you don't. :-) The window color table describes the colors to use for
drawing various parts of the window itself, not the image in the window's
content region, which is what you are drawing.
> What I tried initially was to create a Palette with my entries, used
> palette2CTab, and then placed the CTable into the Pixmap area pointed
> to by the window that I created...
This certainly does something, but I'm not sure what. :-) You took too
many steps. All you want to do is:
(1) build a palette
(2) call GetPalette to see if the window already has a palette;
if so, I believe you can call DisposePalette against it,
but I'm shooting from the hip here as palettes may be shared;
someone else should verify this info
(3) call SetPalette
I sympathize with your plight; finding Palette Manager documentation is
non-trivial these days.
______________________________________________________________________________
Pete Gontier -- MacZealotry, Ink. -- gurgle@dnai.com
Where do I want to go today? Anywhere but Chicago.
---------------------------
End of C.S.M.P. Digest
**********************